package sg.edu.nus.iss.vmcs.interfaces;

import org.eclipse.swt.widgets.Shell;

import sg.edu.nus.iss.vmcs.customer.CustomerUI;
import sg.edu.nus.iss.vmcs.machinery.MachineryController;
import sg.edu.nus.iss.vmcs.machinery.MachineryInterface;
import sg.edu.nus.iss.vmcs.maintenance.MaintenanceController;
import sg.edu.nus.iss.vmcs.maintenance.MaintenanceUI;
import sg.edu.nus.iss.vmcs.system.MainController;
import sg.edu.nus.iss.vmcs.system.SimulationController;
import sg.edu.nus.iss.vmcs.system.TransactionController;
import sg.edu.nus.iss.vmcs.system.VMCSControlUI;

public class SimulationSWTFactory extends InterfaceFactory {
	private static InterfaceFactory instance = null;
	public static InterfaceFactory getInstance() {
		if (instance == null) {
			instance = new SimulationSWTFactory();
		}
		return instance;
	}
	private SimulationSWTFactory() {
		System.out.println("<<Abstract Factory>> An instance of class '" +getClass().getName()+ "' is being constructed.");
	}

	private Shell shell;
	
	@Override
	public MaintenanceUI createMaintenanceUI(MaintenanceController controller) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public MachineryInterface createMachineryInterface(
			MachineryController controller) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public VMCSControlUI createVMCSControlUI(SimulationController controller) {
		SWTSimulatorPanel swtPanel = new SWTSimulatorPanel(controller);
		printClassInstanceCreated(swtPanel.getClass());
		shell = swtPanel.getShell();
		return swtPanel;
	}

	@Override
	public CustomerUI createCustomerUI(TransactionController tc,
			MainController mc) {
		SWTCustomerPanel swtCustPanel = new SWTCustomerPanel(shell, tc);
		printClassInstanceCreated(swtCustPanel.getClass());
		return swtCustPanel;
	}

	private void printClassInstanceCreated(@SuppressWarnings("rawtypes") Class cls) {
		System.out.println("<<Abstract Factory>> An instance of class '"+cls.getName()+"' has been created.");
	}
}
